import { createApp } from 'vue'
import './assets/font_4070313_2z8rwf863hv/iconfont.css'//引入阿里巴巴图标

import App from './App.vue'
import router from './router'

import "./router/dynamicallyAddRoutes.ts"//引入动态路由


import ElementPlus from 'element-plus'
import 'element-plus/dist/index.css'
import * as ElementPlusIconsVue from '@element-plus/icons-vue'

import { createPinia } from 'pinia'
import Persistedstate from 'pinia-plugin-persistedstate' //引入持久化文件

import './utils/dateFormatter'//时间方法


import echarts from './components/echarts/echarts';

import { i18n } from './i18'

import { useUserInfo } from "./stores/admin/index";

const store = createPinia()     //获取状态管理方法
store.use(Persistedstate)   //注册持久化

const app = createApp(App)
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component)
}//全局注册

app.directive('power', {
  mounted(el, binding) {
    let store = useUserInfo()
    let powers = store.user.perms || []
    if (powers[0] == '*') {
      return
    } else {
      let powerModel = binding.value
      if (-1 == powers.indexOf(powerModel)) {
        el?.remove()
      }
    }
  }
})
app.use(i18n)
app.use(store)  //app组件注册状态管理方法
app.use(router)
app.use(ElementPlus)
app.config.globalProperties.$echarts = echarts
app.mount('#app')
